package com.piggy.common.core.web.domain;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

/**
 * Entity基类
 *
 * @author shark
 */

@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class BaseEntity extends BaseTenantEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    /** 分页大小 */
    @ApiModelProperty("分页大小")
    @TableField(exist = false)
    private Integer pageSize;

    /** 当前页数 */
    @ApiModelProperty("当前页数")
    @TableField(exist = false)
    private Integer pageNum;

    /** 排序列 */
    @ApiModelProperty("排序列")
    @TableField(exist = false)
    private String orderByColumn;

    /** 排序的方向desc或者asc */
    @ApiModelProperty(value = "排序的方向", example = "asc,desc")
    @TableField(exist = false)
    private String isAsc;

    /**
     * 创建者
     */
    @TableField(fill = FieldFill.INSERT)
    private String createBy;

    /**
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    /**
     * 更新时间
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    /**
     * 更新者
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private String updateBy;

    /**
     * 备注
     */
    private String remark;

    /**
     * 请求参数
     */
    @TableField(exist = false)
    private Map<String, Object> params = new HashMap<>();

    @ApiModelProperty("创建时间开始")
    @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss")
    //@DateTimeFormat(pattern = "yyyy-MM-dd hh:mm:ss")
    @TableField(exist = false)
    private Date createTimeStart;

    @ApiModelProperty("创建时间结束")
    @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss")
    //@DateTimeFormat(pattern = "yyyy-MM-dd hh:mm:ss")
    @TableField(exist = false)
    private Date createTimeEnd;

}
